/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkg_entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Oswaldo
 */
@Entity
@Table(name = "scat_categoria", catalog = "sisventas_db", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Categoria.findAll", query = "SELECT c FROM Categoria c"),
    @NamedQuery(name = "Categoria.findByCatCodigo", query = "SELECT c FROM Categoria c WHERE c.catCodigo = :catCodigo"),
    @NamedQuery(name = "Categoria.findByCatDescri", query = "SELECT c FROM Categoria c WHERE c.catDescri = :catDescri")})
public class Categoria implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cat_codigo")
    private Integer catCodigo;
    @Size(max = 35)
    @Column(name = "cat_descri")
    private String catDescri;
    @OneToMany(mappedBy = "catCodigo")
    private List<Artiserv> artiservList;
    @OneToMany(mappedBy = "scaCatCodigo")
    private List<Categoria> categoriaList;
    @JoinColumn(name = "sca_cat_codigo", referencedColumnName = "cat_codigo")
    @ManyToOne
    private Categoria scaCatCodigo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "catCodigo")
    private List<Tipcaract> tipcaractList;

    public Categoria() {
    }

    public Categoria(Integer catCodigo) {
        this.catCodigo = catCodigo;
    }

    public Integer getCatCodigo() {
        return catCodigo;
    }

    public void setCatCodigo(Integer catCodigo) {
        this.catCodigo = catCodigo;
    }

    public String getCatDescri() {
        return catDescri;
    }

    public void setCatDescri(String catDescri) {
        this.catDescri = catDescri;
    }

    @XmlTransient
    public List<Artiserv> getArtiservList() {
        return artiservList;
    }

    public void setArtiservList(List<Artiserv> artiservList) {
        this.artiservList = artiservList;
    }

    @XmlTransient
    public List<Categoria> getCategoriaList() {
        return categoriaList;
    }

    public void setCategoriaList(List<Categoria> categoriaList) {
        this.categoriaList = categoriaList;
    }

    public Categoria getScaCatCodigo() {
        return scaCatCodigo;
    }

    public void setScaCatCodigo(Categoria scaCatCodigo) {
        this.scaCatCodigo = scaCatCodigo;
    }

    @XmlTransient
    public List<Tipcaract> getTipcaractList() {
        return tipcaractList;
    }

    public void setTipcaractList(List<Tipcaract> tipcaractList) {
        this.tipcaractList = tipcaractList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (catCodigo != null ? catCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Categoria)) {
            return false;
        }
        Categoria other = (Categoria) object;
        if ((this.catCodigo == null && other.catCodigo != null) || (this.catCodigo != null && !this.catCodigo.equals(other.catCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return catDescri;
    }
    
}
